package com.appsflyer.share; import android.content.Context; import android.os.AsyncTask; import com.appsflyer.AFLogger; import com.appsflyer.AppsFlyerLib; import com.appsflyer.AppsFlyerProperties; import com.appsflyer.ServerConfigHandler; import com.appsflyer.ServerParameters; import java.lang.ref.WeakReference; import java.net.HttpURLConnection; import java.net.URL; import java.util.HashMap; import java.util.Map; public class CrossPromotionHelper { /* access modifiers changed from: package-private */ public static class b extends AsyncTask<String, Void, Void> { /* renamed from: ˋ reason: contains not printable characters */ private WeakReference<Context> f200; /* renamed from: ˎ reason: contains not printable characters */ private d f201; /* renamed from: ˏ reason: contains not printable characters */ private boolean f202; b(d dVar, Context context, boolean z) { this.f201 = dVar; this.f200 = new WeakReference<>(context); this.f202 = z; } /* access modifiers changed from: private */ /* JADX WARNING: Removed duplicated region for block: B:27:0x0082 */ /* JADX WARNING: Removed duplicated region for block: B:32:0x00a8 */ /* renamed from: ˋ reason: contains not printable characters */ public Void doInBackground(String... strArr) { HttpURLConnection httpURLConnection; HttpURLConnection httpURLConnection2 = null; if (!this.f202) { try { String str = strArr[0]; HttpURLConnection httpURLConnection3 = (HttpURLConnection) new URL(str).openConnection(); try { httpURLConnection3.setConnectTimeout(10000); httpURLConnection3.setInstanceFollowRedirects(false); int responseCode = httpURLConnection3.getResponseCode(); if (responseCode == 200) { AFLogger.afInfoLog("Cross promotion impressions success: ".concat(String.valueOf(str)), false); } else if (responseCode == 301 || responseCode == 302) { AFLogger.afInfoLog("Cross promotion redirection success: ".concat(String.valueOf(str)), false); if (!(this.f201 == null || this.f200.get() == null)) { this.f201.m197(httpURLConnection3.getHeaderField(Constants.HTTP_REDIRECT_URL_HEADER_FIELD)); this.f201.m196(this.f200.get()); } } else { AFLogger.afInfoLog(new StringBuilder("call to ").append(str).append(" failed: ").append(responseCode).toString()); } if (httpURLConnection3 != null) { httpURLConnection3.disconnect(); } } catch (Throwable th) { httpURLConnection2 = httpURLConnection3; th = th; if (httpURLConnection2 != null) { } throw th; } } catch (Throwable th2) { th = th2; if (httpURLConnection2 != null) { httpURLConnection2.disconnect(); } throw th; } } return null; } } public static void trackAndOpenStore(Context context, String str, String str2) { trackAndOpenStore(context, str, str2, null); } public static void trackAndOpenStore(Context context, String str, String str2, Map<String, String> map) { LinkGenerator r0 = m190(context, str, str2, map, ServerConfigHandler.getUrl(Constants.BASE_URL_APP_APPSFLYER_COM)); if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false)) { AFLogger.afInfoLog("CustomerUserId not set, track And Open Store is disabled", true); return; } HashMap hashMap = new HashMap(); if (map != null) { hashMap.putAll(map); } hashMap.put("af_campaign", str2); AppsFlyerLib.getInstance().trackEvent(context, "af_cross_promotion", hashMap); new b(new d(), context, AppsFlyerLib.getInstance().isTrackingStopped()).execute(r0.generateLink()); } public static void trackCrossPromoteImpression(Context context, String str, String str2) { if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false)) { AFLogger.afInfoLog("CustomerUserId not set, Promote Impression is disabled", true); return; } LinkGenerator r0 = m190(context, str, str2, null, ServerConfigHandler.getUrl("https://impression.%s")); new b(null, null, AppsFlyerLib.getInstance().isTrackingStopped()).execute(r0.generateLink()); } /* renamed from: ˎ reason: contains not printable characters */ private static LinkGenerator m190(Context context, String str, String str2, Map<String, String> map, String str3) { LinkGenerator linkGenerator = new LinkGenerator("af_cross_promotion"); linkGenerator.m195(str3).m194(str).addParameter(Constants.URL_SITE_ID, context.getPackageName()); if (str2 != null) { linkGenerator.setCampaign(str2); } if (map != null) { linkGenerator.addParameters(map); } String string = AppsFlyerProperties.getInstance().getString(ServerParameters.ADVERTISING_ID_PARAM); if (string != null) { linkGenerator.addParameter(Constants.URL_ADVERTISING_ID, string); } return linkGenerator; } }